home *** CD-ROM | disk | FTP | other *** search
/ Aminet 4 / Aminet 4 - November 1994.iso / aminet / dev / obero / oberon_lib.lha / oberon-a / source1.lha / source / Amiga / CDDevice.mod < prev    next >
Text File  |  1994-08-08  |  16KB  |  371 lines

  1. (*************************************************************************
  2.  
  3.      $RCSfile: CDDevice.mod $
  4.   Description: Interface to cd.device
  5.  
  6.    Created by: fjc (Frank Copeland)
  7.     $Revision: 3.1 $
  8.       $Author: fjc $
  9.         $Date: 1994/08/08 01:16:03 $
  10.  
  11.   $VER: cd.h 1.11 (12.8.93)
  12.   Includes Release 40.15
  13.  
  14.   (C) Copyright 1992-1993 Commodore-Amiga, Inc.
  15.       All Rights Reserved
  16.  
  17.   Oberon-A Interface Copyright © 1994, Frank Copeland.
  18.   This file is part of the Oberon-A Interface.
  19.   See Oberon-A.doc for conditions of use and distribution.
  20.  
  21. *************************************************************************)
  22.  
  23. MODULE CDDevice;
  24.  
  25. (*
  26. ** $C- CaseChk       $I- IndexChk  $L+ LongAdr   $N- NilChk
  27. ** $P- PortableCode  $R- RangeChk  $S- StackChk  $T- TypeChk
  28. ** $V- OvflChk       $Z- ZeroVars
  29. *)
  30.  
  31. IMPORT E := Exec, SYS := SYSTEM;
  32.  
  33. (**************************************************************************
  34.  *                                                                        *
  35.  *   CD Commands                                                          *
  36.  *                                                                        *
  37.  **************************************************************************)
  38.  
  39. CONST
  40.  
  41.   reset *        = 1;
  42.   read *         = 2;
  43.   write *        = 3;
  44.   update *       = 4;
  45.   clear *        = 5;
  46.   stop *         = 6;
  47.   start *        = 7;
  48.   flush *        = 8;
  49.   motor *        = 9;
  50.   seek *         = 10;
  51.   format *       = 11;
  52.   remove *       = 12;
  53.   changeNum *    = 13;
  54.   changeState *  = 14;
  55.   protStatus *   = 15;
  56.  
  57.   getDriveType * = 18;
  58.   getNumTracks * = 19;
  59.   addChangeInt * = 20;
  60.   remChangeInt * = 21;
  61.   getGeometry *  = 22;
  62.   eject *        = 23;
  63.  
  64.  
  65.   info *         = 32;
  66.   config *       = 33;
  67.   tocMSF *       = 34;
  68.   tocLSN *       = 35;
  69.  
  70.   readXL *       = 36;
  71.  
  72.   playTrack *    = 37;
  73.   playMSF *      = 38;
  74.   playLSN *      = 39;
  75.   pause *        = 40;
  76.   search *       = 41;
  77.  
  78.   qCodeMSF *     = 42;
  79.   qCodeLSN *     = 43;
  80.   attenuate *    = 44;
  81.  
  82.   addFrameInt *  = 45;
  83.   remFrameInt *  = 46;
  84.  
  85.  
  86. (**************************************************************************
  87.  *                                                                        *
  88.  *   Device Driver Error Codes                                            *
  89.  *                                                                        *
  90.  **************************************************************************)
  91.  
  92. CONST
  93.  
  94.   errOpenFail *       = -1;  (* device/unit failed to open   *)
  95.   errAborted *        = -2;  (* request terminated early             *)
  96.   errNoCmd *          = -3;  (* command not supported by device      *)
  97.   errBadLength *      = -4;  (* invalid length (IO_LENGTH/IO_OFFSET) *)
  98.   errBadAddress *     = -5;  (* invalid address (IO_DATA misaligned) *)
  99.   errUnitBusy *       = -6;  (* device opens ok, but unit is busy    *)
  100.   errSelfTest *       = -7;  (* hardware failed self-test            *)
  101.  
  102.   errNotSpecified *   = 20;  (* general catchall                     *)
  103.   errNoSecHdr *       = 21;  (* couldn't even find a sector          *)
  104.   errBadSecPreamble * = 22;  (* sector looked wrong                  *)
  105.   errBadSecID *       = 23;  (* ditto                                *)
  106.   errBadHdrSum *      = 24;  (* header had incorrect checksum        *)
  107.   errBadSecSum *      = 25;  (* data had incorrect checksum          *)
  108.   errTooFewSecs *     = 26;  (* couldn't find enough sectors         *)
  109.   errBadSecHdr *      = 27;  (* another "sector looked wrong"        *)
  110.   errWriteProt *      = 28;  (* can't write to a protected disk      *)
  111.   errNoDisk *         = 29;  (* no disk in the drive                 *)
  112.   errSeekError *      = 30;  (* couldn't find track 0                *)
  113.   errNoMem *          = 31;  (* ran out of memory                    *)
  114.   errBadUnitNum *     = 32;  (* asked for a unit > NUMUNITS          *)
  115.   errBadDriveType *   = 33;  (* not a drive cd.device understands    *)
  116.   errDriveInUse *     = 34;  (* someone else allocated the drive     *)
  117.   errPostReset *      = 35;  (* user hit reset; awaiting doom        *)
  118.   errBadDataType *    = 36;  (* data on disk is wrong type   *)
  119.   errInvalidState *   = 37;  (* invalid cmd under current conditions *)
  120.  
  121.   errPhase *          = 42;  (* illegal or unexpected SCSI phase     *)
  122.   errNoBoard *        = 50;  (* open failed for non-existant board   *)
  123.  
  124.  
  125.  
  126. (**************************************************************************
  127.  *                                                                        *
  128.  * Configuration                                                          *
  129.  *                                                                        *
  130.  *       The drive is configured by TagList items defined as follows:     *
  131.  *                                                                        *
  132.  **************************************************************************)
  133.  
  134. CONST
  135.  
  136.   tagPlaySpeed *   = 00001H;
  137.   tagReadSpeed *   = 00002H;
  138.   tagReadXLSpeed * = 00003H;
  139.   tagSectorSize *  = 00004H;
  140.   tagXLECC *       = 00005H;
  141.   tagEjectReset *  = 00006H;
  142.  
  143.  
  144. (**************************************************************************
  145.  *                                                                        *
  146.  * Information                                                            *
  147.  *                                                                        *
  148.  *      Information/Status structure describes current speed settings     *
  149.  *      for read and play commands, sector size, audio attenuation        *
  150.  *      precision, and drive status.                                      *
  151.  *                                                                        *
  152.  **************************************************************************)
  153.  
  154. TYPE
  155.  
  156.   CDInfoPtr * = CPOINTER TO CDInfo;
  157.   CDInfo  * = RECORD        (*                                Default       *)
  158.     playSpeed *      : E.UWORD; (* Audio play speed       (75)              *)
  159.     readSpeed *      : E.UWORD; (* Data-rate of CD_READ command   (Max)     *)
  160.     readXLSpeed *    : E.UWORD; (* Data-rate of CD_READXL command (75)      *)
  161.     sectorSize *     : E.UWORD; (* Number of bytes per sector     (2048)    *)
  162.     xlECC *          : E.UWORD; (* CDXL ECC enabled/disabled                *)
  163.     ejectReset *     : E.UWORD; (* Reset on eject enabled/disabled          *)
  164.     reserved1 *      : ARRAY 4 OF E.UWORD; (* Reserved for future expansion *)
  165.     maxSpeed *       : E.UWORD; (* Maximum speed drive can handle (75, 150) *)
  166.     audioPrecision * : E.UWORD; (* 0 = no attenuator, 1 = mute only,        *)
  167.                                 (* other = (# levels - 1)                   *)
  168.     status *         : E.UWORD; (* See flags below                          *)
  169.     reserved2 *      : ARRAY 4 OF E.UWORD; (* Reserved for future expansion *)
  170.   END;
  171.  
  172. CONST
  173.  
  174. (* Flags for Status *)
  175.  
  176.   stsClosed *    = 0;  (* Drive door is closed                        *)
  177.   stsDisk *      = 1;  (* A disk has been detected                    *)
  178.   stsSpin *      = 2;  (* Disk is spinning (motor is on)              *)
  179.   stsTOC *       = 3;  (* Table of contents read.  Disk is valid.     *)
  180.   stsCDRom *     = 4;  (* Track 1 contains CD-ROM data                *)
  181.   stsPlaying *   = 5;  (* Audio is playing                            *)
  182.   stsPaused *    = 6;  (* Pause mode (pauses on play command)         *)
  183.   stsSearch *    = 7;  (* Search mode (Fast Forward/Fast Reverse)     *)
  184.   stsDirection * = 8;  (* Search direction (0 = Forward, 1 = Reverse) *)
  185.  
  186. (* Modes for CD_SEARCH *)
  187.  
  188.   modeNormal *   = 0;  (* Normal play at current play speed    *)
  189.   modeFFwd *     = 1;  (* Fast forward play (skip-play forward)*)
  190.   modeFRev *     = 2;  (* Fast reverse play (skip-play reverse)*)
  191.  
  192.  
  193. (**************************************************************************
  194.  *                                                                        *
  195.  * Position Information                                                   *
  196.  *                                                                        *
  197.  *      Position information can be described in two forms: MSF and LSN   *
  198.  *      form.  MSF (Minutes, Seconds, Frames) form is a time encoding.    *
  199.  *      LSN (Logical Sector Number) form is frame (sector) count.         *
  200.  *      The desired form is selected using the io_Flags field of the      *
  201.  *      IOStdReq structure.  The flags and the union are described        *
  202.  *      below.                                                            *
  203.  *                                                                        *
  204.  **************************************************************************)
  205.  
  206. TYPE
  207.  
  208.   RMSFPtr * = CPOINTER TO RMSF;
  209.   RMSF  * = RECORD
  210.     reserved * : E.UBYTE;  (* Reserved (always zero) *)
  211.     minute *   : E.UBYTE;  (* Minutes (0-72ish)      *)
  212.     second *   : E.UBYTE;  (* Seconds (0-59)         *)
  213.     frame *    : E.UBYTE;  (* Frame   (0-74)         *)
  214.   END;
  215.  
  216.   RLSNPtr * = CPOINTER TO RLSN;
  217.   RLSN  * = RECORD
  218.     lsn * : E.ULONG;       (* Logical Sector Number  *)
  219.   END;
  220.  
  221.  
  222. (**************************************************************************
  223.  *                                                                        *
  224.  * CD Transfer Lists                                                      *
  225.  *                                                                        *
  226.  *      A CDXL node is a double link node; however only single linkage    *
  227.  *      is used by the device driver.  If you wish to construct a         *
  228.  *      transfer list manually, it is only neccessary to define the       *
  229.  *      mln_Succ pointer of the MinNode.  You may also use the Exec       *
  230.  *      list functions by defining a List or MinList structure and by     *
  231.  *      using the AddHead/AddTail functions to create the list.  This     *
  232.  *      will create a double-linked list.  Although a double-linked       *
  233.  *      list is not required by the device driver, you may wish use it    *
  234.  *      for your own purposes.  Don't forget to initialize the            *
  235.  *      the List/MinList before using it!                                 *
  236.  *                                                                        *
  237.  **************************************************************************)
  238.  
  239. TYPE
  240.  
  241.   CDXLPtr * = CPOINTER TO CDXL;
  242.   CDXL  * = RECORD (E.MinNode) (* double linkage                  *)
  243.     buffer *  : E.APTR;        (* data destination (word aligned) *)
  244.     length *  : LONGINT;       (* must be even # bytes            *)
  245.     actual *  : LONGINT;       (* bytes transferred               *)
  246.     intData * : E.APTR;        (* interrupt server data segment   *)
  247.     IntCode * : E.PROC;        (* interrupt server code entry     *)
  248.   END;
  249.  
  250.  
  251. (**************************************************************************
  252.  *                                                                        *
  253.  * CD Table of Contents                                                   *
  254.  *                                                                        *
  255.  *      The CD_TOC command returns an array of CDTOC entries.             *
  256.  *      Entry zero contains summary information describing how many       *
  257.  *      tracks the disk has and the play-time of the disk.                *
  258.  *      Entries 1 through N (N = Number of tracks on disk) contain        *
  259.  *      information about the track.                                      *
  260.  *                                                                        *
  261.  **************************************************************************)
  262.  
  263. TYPE
  264.  
  265.   TOCSummaryPtr * = CPOINTER TO TOCSummary;
  266.   TOCSummary  * = RECORD
  267.     firstTrack * : E.UBYTE; (* First track on disk (always 1)            *)
  268.     lastTrack *  : E.UBYTE; (* Last track on disk                        *)
  269.   END;
  270.  
  271.   TOCSummaryMSFPtr * = CPOINTER TO TOCSummaryMSF;
  272.   TOCSummaryMSF  * = RECORD (TOCSummary)
  273.     leadOut * : RMSF;       (* Beginning of lead-out track (end of disk) *)
  274.   END;
  275.  
  276.   TOCSummaryLSNPtr * = CPOINTER TO TOCSummaryLSN;
  277.   TOCSummaryLSN  * = RECORD (TOCSummary)
  278.     leadOut * : RLSN;       (* Beginning of lead-out track (end of disk) *)
  279.   END;
  280.  
  281.   TOCEntryPtr * = CPOINTER TO TOCEntry;
  282.   TOCEntry  * = RECORD
  283.     ctlAdr * : E.UBYTE;     (* Q-Code info                  *)
  284.     track *  : E.UBYTE;     (* Track number                 *)
  285.   END;
  286.  
  287.   TOCEntryMSFPtr * = CPOINTER TO TOCEntryMSF;
  288.   TOCEntryMSF  * = RECORD (TOCEntry)
  289.     position * : RMSF;      (* Start position of this track *)
  290.   END;
  291.  
  292.   TOCEntryLSNPtr * = CPOINTER TO TOCEntryLSN;
  293.   TOCEntryLSN  * = RECORD (TOCEntry)
  294.     position * : RLSN;      (* Start position of this track *)
  295.   END;
  296.  
  297.   CDTOCPtr * = CPOINTER TO CDTOC;
  298.   CDTOC  * = RECORD END;
  299.  
  300.   CDTOCMSFPtr * = CPOINTER TO CDTOCMSF;
  301.   CDTOCMSF  * = RECORD (CDTOC)
  302.     summary * : TOCSummaryMSF; (* First entry (0) is summary information *)
  303.     entry *   : ARRAY 256 OF TOCEntryMSF; (* Entries 1-N are track entries          *)
  304.   END;
  305.  
  306.   CDTOCLSNPtr * = CPOINTER TO CDTOCLSN;
  307.   CDTOCLSN  * = RECORD (CDTOC)
  308.     summary * : TOCSummaryLSN; (* First entry (0) is summary information *)
  309.     entry *   : ARRAY 256 OF TOCEntryLSN; (* Entries 1-N are track entries          *)
  310.   END;
  311.  
  312.  
  313. (**************************************************************************
  314.  *                                                                        *
  315.  * Q-Code Packets                                                         *
  316.  *                                                                        *
  317.  *      Q-Code packets are only returned when audio is playing.           *
  318.  *      Currently, only position packets are returned (ADR_POSITION)      *
  319.  *      The other ADR_ types are almost never encoded on the disk         *
  320.  *      and are of little use anyway.  To avoid making the QCode          *
  321.  *      structure a union, these other ADR_ structures are not defined.   *
  322.  *                                                                        *
  323.  **************************************************************************)
  324.  
  325. TYPE
  326.  
  327.   QCodeMSFPtr * = CPOINTER TO QCodeMSF;
  328.   QCodeMSF  * = RECORD
  329.     ctlAdr *        : E.UBYTE; (* Data type / QCode type           *)
  330.     track *         : E.UBYTE; (* Track number                     *)
  331.     index *         : E.UBYTE; (* Track subindex number            *)
  332.     zero *          : E.UBYTE; (* The "Zero" byte of Q-Code packet *)
  333.     trackPosition * : RMSF;    (* Position from start of track     *)
  334.     diskPosition *  : RMSF;    (* Position from start of disk      *)
  335.   END;
  336.  
  337.   QCodeLSNPtr * = CPOINTER TO QCodeLSN;
  338.   QCodeLSN  * = RECORD
  339.     ctlAdr *        : E.UBYTE; (* Data type / QCode type           *)
  340.     track *         : E.UBYTE; (* Track number                     *)
  341.     index *         : E.UBYTE; (* Track subindex number            *)
  342.     zero *          : E.UBYTE; (* The "Zero" byte of Q-Code packet *)
  343.     trackPosition * : RLSN;    (* Position from start of track     *)
  344.     diskPosition *  : RLSN;    (* Position from start of disk      *)
  345.   END;
  346.  
  347. CONST
  348.  
  349.   ctlAdrCtlMask * = 0F0H;  (* Control field *)
  350.  
  351.   ctlCtlMask *    = 0D0H;  (* To be ANDed with CtlAdr before compared  *)
  352.  
  353.   ctl2Aud *       = 000H;  (* 2 audio channels without preemphasis     *)
  354.   ctl2AudEmph *   = 010H;  (* 2 audio channels with preemphasis        *)
  355.   ctl4Aud *       = 080H;  (* 4 audio channels without preemphasis     *)
  356.   ctl4AudEmph *   = 090H;  (* 4 audio channels with preemphasis        *)
  357.   ctlData *       = 040H;  (* CD-ROM Data                              *)
  358.  
  359.   ctlCopyMask *   = 020H;  (* To be ANDed with CtlAdr before compared  *)
  360.  
  361.   ctlCopy *       = 020H;  (* When true, this audio/data can be copied *)
  362.  
  363.   ctlAdrAdrMask * = 00FH;  (* Address field                            *)
  364.  
  365.   adrPosition *   = 001H;  (* Q-Code is position information   *)
  366.   adrUPC *        = 002H;  (* Q-Code is UPC information (not used)     *)
  367.   adrISRC *       = 003H;  (* Q-Code is ISRC (not used)                *)
  368.   adrHybrid *     = 005H;  (* This disk is a hybrid disk               *)
  369.  
  370. END CDDevice.
  371.